package com.petdog.infrastructure.mapper;

import com.petdog.infrastructure.entity.BreedInfo;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface BreedInfoMapper {
    /**
     * 根据ID查询犬种信息
     */
    @Select("SELECT * FROM breed_info WHERE breed_id = #{breedId}")
    BreedInfo selectById(@Param("breedId") Integer breedId);

    /**
     * 根据品种名称查询犬种信息
     */
    @Select("SELECT * FROM breed_info WHERE breed_name = #{breedName}")
    BreedInfo selectByName(@Param("breedName") String breedName);

    /**
     * 查询所有犬种信息
     */
    @Select("SELECT * FROM breed_info")
    List<BreedInfo> selectAll();

    /**
     * 插入犬种信息
     */
    @Insert("INSERT INTO breed_info (breed_name, scientific_name, origin_country, size, weight_range, height_range, " +
            "life_expectancy, personality, appearance, grooming_needs, exercise_needs, health_concerns, " +
            "trainability, suitable_for, image_url, description, popularity_rank) " +
            "VALUES (#{breedName}, #{scientificName}, #{originCountry}, #{size}, #{weightRange}, #{heightRange}, " +
            "#{lifeExpectancy}, #{personality}, #{appearance}, #{groomingNeeds}, #{exerciseNeeds}, #{healthConcerns}, " +
            "#{trainability}, #{suitableFor}, #{imageUrl}, #{description}, #{popularityRank})")
    @Options(useGeneratedKeys = true, keyProperty = "breedId")
    int insert(BreedInfo breedInfo);

    /**
     * 更新犬种信息
     */
    @Update("UPDATE breed_info SET breed_name = #{breedName}, scientific_name = #{scientificName}, " +
            "origin_country = #{originCountry}, size = #{size}, weight_range = #{weightRange}, " +
            "height_range = #{heightRange}, life_expectancy = #{lifeExpectancy}, " +
            "personality = #{personality}, appearance = #{appearance}, grooming_needs = #{groomingNeeds}, " +
            "exercise_needs = #{exerciseNeeds}, health_concerns = #{healthConcerns}, " +
            "trainability = #{trainability}, suitable_for = #{suitableFor}, " +
            "image_url = #{imageUrl}, description = #{description}, " +
            "popularity_rank = #{popularityRank} WHERE breed_id = #{breedId}")
    int update(BreedInfo breedInfo);

    /**
     * 根据ID删除犬种信息
     */
    @Delete("DELETE FROM breed_info WHERE breed_id = #{breedId}")
    int deleteById(@Param("breedId") Integer breedId);
}
